﻿using System.Collections.Generic;
using T.FAS.Runtime.Base.Entity;
using T.FAS.Runtime.Metadata.Entity.DataModel;

namespace T.FAS.Runtime.DataAccess.SGSPI
{
    public interface IStateMachineRTPService
    {
        /// <summary>
        /// 状态机ChangeState事件，触发状态变换的事件以及动作
        /// </summary>
        /// <param name="CDOID"></param>
        /// <param name="ColKey"></param>
        /// <param name="EventKey"></param>
        /// <param name="record"></param>
        /// <returns></returns>
        TResult ChangeState(string CDOID, string ColKey, string EventKey, TRecord record);

        /// <summary>
        /// 审批流使用，触发状态变换时间，更改单据状态
        /// </summary>
        /// <param name="CDOID"></param>
        /// <param name="ColKey"></param>
        /// <param name="EventKey"></param>
        /// <param name="BillId"></param>
        /// <param name="Source"></param>
        /// <returns></returns>
        TResult FireEvent(string CDOID, string ColKey, string EventKey, string BillId, string Source = null);

        /// <summary>
        /// CDO给审批流提供的方法，前置条件为BillID单据已存在，只需要执行Update方法
        /// </summary>
        /// <param name="cdoId">CDO元数据id</param>
        /// <param name="colKey">绑定状态机的列名</param>
        /// <param name="eventKey">状态机事件Key</param>
        /// <param name="record">单据id</param>
        /// <param name="source">来源</param>
        /// <returns></returns>
        TResult FireEventWithTRecord(string cdoId, string colKey, string eventKey, TRecord record, string source = null);

        /// <summary>
        /// 获取下阶段状态集合（包括本状态）
        /// </summary>
        /// <param name="StateMachineID"></param>
        /// <param name="stateKey"></param>
        /// <returns></returns>
        List<TState> GetTransitionStates(string StateMachineID, int stateKey, TRecord record = null);
    }
}